package com.example.jpetstoreclient.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

@Data
@TableName("user")
public class User {
    @NotBlank(message = "用户名不能为空")
    @Nullable
    private String username;
    @NotBlank(message = "密码不能为空")
    @Length(min = 6,max = 10,message = "密码长度必须为6-10")
    private String password;

    @Email(message = "邮箱格式不合法")
    private String email;

    @TableField("phone_number")
    @Length(min = 11,max = 11,message = "无效手机号")
    private String phone;

    private String salt;//用于加密密码的盐值

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    //貌似提供无参构造方法即可自动完成映射？
    public User() {
    }

    public User(String username, String password, String email, String phone) {
        this.username = username;
        this.password = password;
        this.email = email;
        this.phone = phone;
    }

}

